﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace Hetymine.Executioner.Controls {
    public class DisplayComboBox : ComboBox {
        public DisplayComboBox() {
            ComboBoxItem item = new ComboBoxItem();

            System.Windows.Forms.Screen prim = System.Windows.Forms.Screen.PrimaryScreen;

            item.Content = "Primary Display" + " (" + prim.Bounds.Width.ToString() + "×" + prim.Bounds.Height.ToString() + ")";
            this.Items.Add(item);
            int display = 0;
            foreach (System.Windows.Forms.Screen s in System.Windows.Forms.Screen.AllScreens) {
                ++display;
                item = new ComboBoxItem();
                item.Content = "Display " + display.ToString() + " (" + s.Bounds.Width.ToString() + "×" + s.Bounds.Height.ToString() + ")";
                this.Items.Add(item);
            }
        }
        
        public int DisplayIndex {
            get {
                return this.SelectedIndex - 1;
            }
            set {
                if (value >= 0 && value < System.Windows.Forms.Screen.AllScreens.Length) {
                    this.SelectedIndex = value + 1;
                }
                else {
                    this.SelectedIndex = 0;
                }
            }
        }
    }
}
